import Vue from 'vue';
import appMain from './app_main'

// 格式化千分位数
Vue.filter('formatTest', function(val) {
    return val + '10086';    
})

Vue.filter('formatMilNum', function(num) {
    if(!num && num !== 0){
        return
    }
    return (num + '') .replace(/d{1,3}(?=(\d{3})+(\. \d*)?$)/g, '$&,');    
})

Vue.filter('formatters', function(val, format) {
    if (typeof (format) === 'function') {
        return format(val)
      } else return val
})

Vue.filter('formatDate', function(val, fmt) {
    if (!val) {
        return ''
    }
    var d = new Date(val)
    let str =  d.getFullYear() + '-' + appMain.formatZero(d.getMonth()) + '-' + appMain.formatZero(d.getDate());
    return str;
})
